package com.sinosoft.bee.services.provider.demo.dao;

import com.sinosoft.bee.services.provider.demo.entity.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author:TobbyQuinn
 * @date:2018/5/14
 * @project:bee
 **/

public interface DemoMapper {


    @Insert("insert into user values(#{id},#{name},#{age})")
    void insertUser(User user);


    @Results(id = "demo", value = {
            @Result(property = "id", column = "id"),
            @Result(property = "name", column = "name"),
            @Result(property = "age", column = "age")
    })
    @Select("select id,name,age from user where id=#{id}")
    User findById(String id);

    @Update("update user set name=#{name},age=#{age} where id=#{id};")
    void updateUserById(User user);

    @Delete("delete from user where id=#{id}")
    void deleteUserById(User user);

    @ResultMap("demo")
    @Select("select id,name,age from user where id=#{id}")
    User findById2(String id);

}
